package com.decorator.main;

import com.decorator.component.Beverage;
import com.decorator.component.Decaf;
import com.decorator.component.Espresso;
import com.decorator.decorator.Milk;
import com.decorator.decorator.Mocha;
import com.decorator.decorator.Soy;

/**
 * 装饰者模式：动态地将责任附加到对象上。 若要扩展功能，装饰者提供了比继承更有弹性 的替代方案。
 * 
 * @author dell
 * 
 */
public class StarbuzzCoffee {

	public static void main(String args[]) {
		Beverage beverage = new Espresso();
		beverage.setSize(2);
		System.out.println(beverage.getDescription() + " $" + beverage.cost());
		beverage = new Mocha(beverage);
		beverage.setSize(2);
		beverage = new Milk(beverage);
		System.out.println(beverage.getDescription() + " $" + beverage.cost());
		Beverage beverage3 = new Decaf();
		beverage3 = new Soy(beverage3);
		beverage3 = new Mocha(beverage3);
		beverage3 = new Milk(beverage3);
		System.out
				.println(beverage3.getDescription() + " $" + beverage3.cost());
	}

}
